package com.glsc.ngateway.common.api.filetransfer.feign;

import com.glsc.ngateway.common.api.common.config.FeignMultipartSupportConfig;
import com.glsc.ngateway.common.api.filetransfer.dto.CommonFileDto;
import com.glsc.ngateway.common.api.filetransfer.dto.CommonFileUploadDto;
import com.glsc.ngateway.common.api.filetransfer.dto.ReportShowResponse;
import com.glsc.ngateway.common.api.filetransfer.resp.FileTransferResponse;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@FeignClient(value = "eureka-client-filetransfer", configuration = FeignMultipartSupportConfig.class)
interface IFeignCommonFileService {


    /**
     * 文件上传或者文件更新
     *
     * @param
     * @return
     */
    @PostMapping(value = "/gatewayFileTransfer/commonFile/uploadFile")
    FileTransferResponse<CommonFileDto> uploadFile(@RequestPart("file") MultipartFile file,
                                                   @ApiParam(value = "系统编码-必传") @RequestParam(required = true) String systemCode,
                                                   @ApiParam(value = "文件id-更新文件时必传，不传则表示新增") @RequestParam(required = false) String fileId,
                                                   @ApiParam(value = "创建者oa账号") @RequestParam(required = false) String oaAccount,
                                                   @ApiParam(value = "创建者姓名") @RequestParam(required = false) String creatorName,
                                                   @ApiParam(value = "文件描述") @RequestParam(required = false) String fileDesc);

    /**
     * 文件下载-获取文件byte数组
     *
     * @param fileId
     * @param systemCode
     * @return
     */
    @ApiImplicitParams({@ApiImplicitParam(name = "fileId", value = "文件id", required = true, paramType = "path", dataTypeClass = String.class),
            @ApiImplicitParam(name = "systemCode", value = "系统编码", required = true, paramType = "path", dataTypeClass = String.class)})
    @GetMapping("/gatewayFileTransfer/commonFile/download")
    FileTransferResponse<byte[]> download(String fileId, String systemCode);

    /**
     * 通用文件预览接口
     *
     * @param fileId
     * @return
     */
    @ApiImplicitParams({@ApiImplicitParam(name = "fileId", value = "文件id", required = true, paramType = "path", dataTypeClass = String.class)})
    @GetMapping("/gatewayFileTransfer/commonFile/showDoc")
    FileTransferResponse<ReportShowResponse> show(String fileId);

    /**
     * 文件预览专用下载接口
     *
     * @param fileId
     * @return
     */
    @ApiImplicitParams({@ApiImplicitParam(name = "fileId", value = "文件id", required = true, paramType = "path", dataTypeClass = String.class)})
    @GetMapping("/gatewayFileTransfer/commonFile/showDoc/download")
    FileTransferResponse<byte[]> getContentById4ShowDoc(String fileId);
}